#!/bin/bash
source ~/command/common

_oper=0
_reg=""
_func=""

function genrate_param_from_model() {
    if __mac ;then
        pbpaste|sed 's#:.*//#, //#'|pbcopy
    else
        cat /dev/clipboard|sed 's#:.*//#, //#' > /dev/clipboard
    fi
}

function genrate_param_without_comment() {
    if __mac ;then
        pbpaste|sed 's#\s*//.*$##'|sed 's/ = .*/,/'|pbcopy
    else
         cat /dev/clipboard|sed 's#\s*//.*$##'|sed 's/ = .*/,/' > /dev/clipboard
    fi
}

function genrate_param_for_one() {
    if __mac ;then
        pbpaste|sed 's#,#: 1,#'|pbcopy
    else
        cat /dev/clipboard|sed 's#\s*//.*$##'|sed 's/.* //' > /dev/clipboard
    fi
}

function genrate_param_for_js() {
    if __mac ;then
        pbpaste|sed "s#\(\w\+\)[,]*\s*\(//.*\)#\1: '', \2#"|pbcopy
    else
        cat /dev/clipboard|sed "s#\(\w\+\)[,]*\s*\(//.*\)#\1: '', \2#" > /dev/clipboard
    fi
}

function change_english_symbol_to_chinese() {
    if __mac ;then
        pbpaste|sed "s#,#，#g"|sed "s#:#：#g"|sed "s#\.#。#g"|pbcopy
    else
        cat /dev/clipboard|sed "s#,#，#g"|sed "s#:#：#g"|sed "s#\.#。#g" > /dev/clipboard
    fi
}

function change_chinese_symbol_to_english() {
    if __mac ;then
        pbpaste|sed "s#，#,#g"|sed "s#：#:#g"|sed "s#。#.#g"|pbcopy
    else
        cat /dev/clipboard|sed "s#，#,#g"|sed "s#：#:#g"|sed "s#。#.#g" > /dev/clipboard
    fi
}

function getSubmitComments() {
    str=""
    while read line;do
        str="${str}\`${line}\`,"
    done
    str="${str}\`${line}\`,"
    if [ "${_func:0:1}" = "=" ];then
        _func="m=>${_func:1}"
    else
        _func="'${_func}'";
    fi
    node -e " \
    var _ = require('lodash'); \
    var m = require('moment'); \
    var list = [${str}]; \
    var i = 0; \
    var ret = list.filter(o=>o).map(o=>{ \
        var c = o.match(/(.*)(${_reg})(.*)/); \
        var f = ${_func}; \
        c && (i++); \
        return !c ? o : c[1] + (typeof(f) === 'function' ? f(c[2], i) : f) + c[3]; \
    }); \
    console.log(ret.join('\n')); \
    "
}

function add_for_number() {
    _reg="${1%%:*}"
    _func="${1#*:}"
    echo _reg is:${_reg}
    echo _func is:${_func}
    if [ "$_reg:$_func" != "$1" ];then
        echo "格式：xt -a reg:num|str|func"
        exit
    fi
    if [ "$_reg" = "*" ];then
        _reg="^.*$"
    fi
    if __mac ;then
        pbpaste|getSubmitComments|pbcopy
    else
        cat /dev/clipboard|getSubmitComments > /dev/clipboard
    fi
}

function get_text_from_xml() {
    if __mac ;then
        pbpaste|sed "s#<[^>]*>##g"|sed "s#&nbsp;# #g"|pbcopy
    else
        cat /dev/clipboard|sed "s#<[^>]*>##g"|sed "s#&nbsp;# #g" > /dev/clipboard
    fi
}

function join_all_comment() {
    if __mac ;then
        pbpaste|sed -n '/,/p'|sed 's#.*//##'|sed 's#;$##'|sed ':a;N;s/\r\n\|\n\|\r/;/;t a;'|pbcopy
    else
        cat /dev/clipboard|sed -n '/,/p'|sed 's#.*//##'|sed 's#;$##'|sed ':a;N;s/\r\n\|\n\|\r/;/;t a;'> /dev/clipboard
    fi
}

function join_all_params() {
    if __mac ;then
        pbpaste|sed -n '/,/p'|sed 's#//.*##'|sed 's#\s*##g'|sed 's#;$##'|sed ':a;N;s/\r\n\|\n\|\r/ /;t a;'|pbcopy
    else
        cat /dev/clipboard|sed -n '/,/p'|sed 's#//.*##'|sed 's#\s*##g'|sed 's#;$##'|sed ':a;N;s/\r\n\|\n\|\r/ /;t a;'> /dev/clipboard
    fi
}
# .item { border-width: 1px; } -> item: { borderWidth: 1 },
function class_to_style() {
    if __mac ;then
        pbpaste|sed 's#^\.\([^ ]*\) *{#\1: {#'|sed 's#;#,#'|sed 's#px##g'|sed 's#}#},#g'|sed 's#-\(\w\)#\u\1#'|sed 's#:\s*\(.*\),#: '\''\1'\'',#'|sed -e 's#:\s*'\''\([0-9]\+\)'\'',#: \1,#'|pbcopy
    else
        cat /dev/clipboard|sed 's#^\.\([^ ]*\) *{#\1: {#'|sed 's#;#,#'|sed 's#px##g'|sed 's#}#},#g'|sed 's#-\(\w\)#\u\1#'|sed 's#:\s*\(.*\),#: '\''\1'\'',#'|sed -e 's#:\s*'\''\([0-9]\+\)'\'',#: \1,#' > /dev/clipboard
    fi
}
function div_to_view() {
    if __mac ;then
        pbpaste|sed 's#div#View#g'|sed 's#span#Text#g'|sed 's#class="\(\w\+\)"#style={styles.\1}#'|pbcopy
    else
        cat /dev/clipboard|sed 's#div#View#g'|sed 's#span#Text#g'|sed 's#class="\(\w\+\)"#style={styles.\1}#' > /dev/clipboard
    fi
}
function change_to_json() {
    local str
    if __mac ;then
        str=`pbpaste`
    else
        str=`cat /dev/clipboard`
    fi
    node -e " \
        const os = require('os'); \
        const fs = require('fs'); \
        const path = require('path'); \
        const utils = require(path.join(os.homedir(), 'command', 'js', 'utils.js')); \
        fs.writeFileSync(path.join(os.homedir(), '.json_temp.json'), utils.stringify(${str}, $1), 'utf-8'); \
    "
    echo -n "结果："
    cat ~/.json_temp.json
    if __mac ;then
        cat ~/.json_temp.json | pbcopy
    else
        cat ~/.json_temp.json  >  /dev/clipboard
    fi
    rm -f ~/.json_temp.json
}
function to_list() {
    node -e " \
        const os = require('os'); \
        const fs = require('fs'); \
        const path = require('path'); \
        const utils = require(path.join(os.homedir(), 'command', 'js', 'utils.js')); \
        utils.paste(async text=>{ \
            const delimiter = '$1'; \
            let list = []; \
            if (delimiter) { \
                list = text.split(delimiter); \
            } else if (/\n/.test(text)) { \
                list = text.split(/\r?\n/); \
            } else { \
                list = text.split(/\s+|，|,|；|;/); \
            } \
            fs.writeFileSync(path.join(os.homedir(), '.json_temp.json'), utils.stringify(list, 0), 'utf-8'); \
        }); \
    "
    echo -n "结果："
    cat ~/.json_temp.json
    if __mac ;then
        cat ~/.json_temp.json | pbcopy
    else
        cat ~/.json_temp.json  >  /dev/clipboard
    fi
    rm -f ~/.json_temp.json
}
function to_list_index() {
    local str code
    if __mac ;then
        str=`pbpaste`
    else
        str=`cat /dev/clipboard`
    fi
    code=" \
    const _ = require('lodash'); \
    const m = require('moment'); \
    const os = require('os'); \
    const path = require('path'); \
    const u = require(path.resolve(os.homedir(),'command/js/utils.js')); \
    const line = \`$1\`; \
    const list = \`$str\`.split(/\\n/); \
    let matches = line.match(/#\d+/g); \
    let f = 0; \
    if (!matches) { \
        matches = line.match(/\d+/g); \
        f = 1; \
    } \
    function value(l) { \
        const e = matches.reduce((r,v)=>r.replace(v,f?l[v]:l[v.substr(1)]), line); \
        return (new Function(\`return \\\`\${e}\\\`\`))({l, _, m, u}); \
    } \
    for (const m of list) {  \
        const l = m.split(/\s+/); \
        let s = value(l); \
        try { s = eval(s) } catch(err) {} \
        console.log(s); \
    } \
    "
    echo -n "结果："
    node -e "$code"
    if __mac ;then
        node -e "$code"|pbcopy
    else
        node -e "$code" > /tmp/.__tmp_file
        cat /tmp/.__tmp_file > /dev/clipboard
        rm -f /tmp/.__tmp_file
    fi
}
function gen_pc_code() {
    local  path _path pre post oldName newName newName1 _oldName _newName oldModule newMoule link line
    pre="${1%,*}"
    post="${1#*,}"
    oldName="${pre%:*}"
    newName="${pre#*:}"
    _oldName="${post%:*}"
    _newName="${post#*:}"
    if [ "$oldName:$newName,$_oldName:$_newName" != "$1" ];then
        echo "格式：oldModule/oldName:newModule/newName"
        exit
    fi
    oldModule="${oldName%/*}"
    newModule="${newName%/*}"
    if [ "$oldName" = "$oldModule" ];then
        oldModule=""
    else
        oldName="${oldName#*/}"
        oldModule="${oldModule}/"
    fi
    if [ "$newName" = "$newModule" ];then
        newModule=""
    else
        newModule="${newModule}/"
        newName="${newName#*/}"
    fi
    if [ -z "${oldModule}" ];then
        echo "格式：oldModule/oldName:newModule/newName"
        exit
    fi
    if [ -z "${newModule}" ];then
        newModule="${oldModule}"
    fi

    _path=`pwd`
    path="${_path%%/project*}"
    if [ "${path}" = "${_path}" ];then
        echo "请在工程中运行"
        exit
    fi
    newName1=`echo $newName|sed 's/^[a-z]/\u&/'`

    if ! [ -d "${path}/project/App/shared/pages/client/pages/${oldModule}${oldName}s" ];then
        echo "${path}/project/App/shared/pages/client/pages/${oldModule}${oldName}s 不存在"
        exit
    fi

    cd "${path}/project/App/shared/pages/client/pages/${oldModule}"
    xr "$oldName:$newName,$_oldName:$_newName" -c "${oldName}s" force
    cd "${path}/project/App/shared/pages/client/pages/${oldModule}${newName}s"
    mkdir -p "${path}/project/App/shared/pages/client/pages/${newModule}"
    mv "${path}/project/App/shared/pages/client/pages/${oldModule}${newName}s" "${path}/project/App/shared/pages/client/pages/${newModule}"

    line=`cat "${path}/project/App/shared/routers/client.js"|sed -n '/const/h;${x;p}'|awk '{print $2}'`
    sed -i '/const '${line}' =/a\const '${newName1}'s = AsyncLoad((cb) => require.ensure([], (require) => cb(require('"'"pages/client/pages/${newModule}${newName}s"'"').default), '"'"${newName1}s"'"'));' "${path}/project/App/shared/routers/client.js"
    sed -i '/const '${newName1}'s =/a\const '${newName1}'Detail = AsyncLoad((cb) => require.ensure([], (require) => cb(require('"'"pages/client/pages/${newModule}${newName}s/pages/detail"'"').default), '"'"${newName1}Detail"'"'));' "${path}/project/App/shared/routers/client.js"
    sed -i '/<\/Route>,/i\\t\t<Route name='"'"${newName1}s"'"' path='"'"${newName}s"'"'>' "${path}/project/App/shared/routers/client.js"
    sed -i '/<\/Route>,/i\\t\t\t<IndexRoute component={'${newName1}'s} onEnter={authenticate} \/>' "${path}/project/App/shared/routers/client.js"
    sed -i '/<\/Route>,/i\\t\t\t<Route name='"'"${newName1}Detail"'"' path='"'"detail"'"' component={'${newName1}'Detail} onEnter={authenticate} />' "${path}/project/App/shared/routers/client.js"
    sed -i '/<\/Route>,/i\\t\t<\/Route>' "${path}/project/App/shared/routers/client.js"

    sed -i '/};/i\\n    // '${_newName}'' "${path}/project/App/server/api/apis.js"
    sed -i '/};/i\    '${newName}'s: query('${newModule%/}' + '"'"get${newName1}List"'"'), // 获取'${_newName}'列表' "${path}/project/App/server/api/apis.js"
    sed -i '/};/i\    '${newName}': query('${newModule%/}' + '"'"get${newName1}Detail"'"'), // 获取'${_newName}'详情' "${path}/project/App/server/api/apis.js"
    sed -i '/};/i\    create'${newName1}': mutation('${newModule%/}' + '"'"create${newName1}"'"'), // 创建'${_newName}'' "${path}/project/App/server/api/apis.js"
    sed -i '/};/i\    modify'${newName1}': mutation('${newModule%/}' + '"'"modify${newName1}"'"'), // 修改'${_newName}'' "${path}/project/App/server/api/apis.js"
    sed -i '/};/i\    remove'${newName1}': mutation('${newModule%/}' + '"'"remove${newName1}"'"'), // 删除'${_newName}'' "${path}/project/App/server/api/apis.js"
    link=`sed -n '{/link:.*'${oldName}s'/{p;q}}' "${path}/project/App/shared/config/sideMenu/system_menu.js"|sed 's/'${oldName}s'/'${newName}s'/'`
    sed -i '/];/i\\t{\n\t\tlabel: '"'"${_newName}列表"'"',\n'"${link}"'\n\t\tkey: '"'"${newName}s"'"',\n\t},' "${path}/project/App/shared/config/sideMenu/system_menu.js"
}

function gen_server_code() {
    local  path _path pre post oldName newName newName1 oldName1 _oldName _newName oldModule newModule link
    pre="${1%,*}"
    post="${1#*,}"
    oldName="${pre%:*}"
    newName="${pre#*:}"
    _oldName="${post%:*}"
    _newName="${post#*:}"
    if [ "$oldName:$newName,$_oldName:$_newName" != "$1" ];then
        echo "格式：oldModule/oldName:newModule/newName"
        exit
    fi
    oldModule="${oldName%/*}"
    newModule="${newName%/*}"
    if [ "$oldName" = "$oldModule" ];then
        oldModule=""
    else
        oldName="${oldName#*/}"
        oldModule="${oldModule}/"
    fi
    if [ "$newName" = "$newModule" ];then
        newModule=""
    else
        newModule="${newModule}/"
        newName="${newName#*/}"
    fi
    if [ -z "${oldModule}" ];then
        echo "格式：oldModule/oldName:newModule/newName"
        exit
    fi
    if [ -z "${newModule}" ];then
        newModule="${oldModule}"
    fi

    _path=`pwd`
    path="${_path%%/project*}"
    if [ "${path}" = "${_path}" ];then
        echo "请在工程中运行"
        exit
    fi
    newName1=`echo $newName|sed 's/^[a-z]/\u&/'`
    oldName1=`echo $oldName|sed 's/^[a-z]/\u&/'`

    if ! [ -f "${path}/project/App/models/${oldModule}${oldName1}Model.js" ];then
        echo "${path}/project/App/models/${oldModule}${oldName1}Model.js 不存在"
        exit
    fi
    if ! [ -d "${path}/project/App/routers/posts/${oldModule}${oldName}" ];then
        echo "${path}/project/App/routers/posts/${oldModule}${oldName} 不存在"
        exit
    fi
    if ! [ -d "${path}/project/test/modules/${oldModule}${oldName}" ];then
        echo "${path}/project/test/modules/${oldModule}${oldName} 不存在"
        exit
    fi

    cd "${path}/project/App/models/${oldModule}"
    xr "$oldName1:$newName1,$_oldName:$_newName" -f "${oldName1}Model.js"
    mkdir -p "${path}/project/App/models/${newModule}"
    mv "${path}/project/App/models/${oldModule}${newName1}Model.js" "${path}/project/App/models/${newModule}"
    sed -i '$a\// '${newModule%/}'' "${path}/project/App/models/index.js"
    sed -i '$a\export '${newName1}'Model from '"'"./${newModule}${newName1}Model"'"'; // '${_newName}'表' "${path}/project/App/models/index.js"

    cd "${path}/project/App/routers/posts/${oldModule}"
    xr "$oldName:$newName,$_oldName:$_newName" -c "${oldName}" force
    mkdir -p "${path}/project/App/routers/posts/${newModule}"
    mv "${path}/project/App/routers/posts/${oldModule}${newName}" "${path}/project/App/routers/posts/${newModule}"

    cd "${path}/project/App/routers/posts/${newModule}"
    if [ -f "index.js" ];then
        sed -i '$a\// '${newName}'' "index.js"
    else
        echo "// ${newName}" > "index.js"
    fi
    sed -i '$a\export create'${newName1}' from '"'"./${newName}/create${newName1}"'"'; // 创建'${_newName}'' "index.js"
    sed -i '$a\export get'${newName1}'List from '"'"./${newName}/get${newName1}List"'"'; // 获取'${_newName}'列表' "index.js"
    sed -i '$a\export get'${newName1}'Detail from '"'"./${newName}/get${newName1}Detail"'"'; // 获取'${_newName}'详情' "index.js"
    sed -i '$a\export modify'${newName1}' from '"'"./${newName}/modify${newName1}"'"'; // 修改'${_newName}'' "index.js"
    sed -i '$a\export remove'${newName1}' from '"'"./${newName}/remove${newName1}"'"'; // 删除'${_newName}'' "index.js"

    cd "${path}/project/test/modules/${oldModule}"
    xr "$oldName:$newName,$_oldName:$_newName" -c "${oldName}" force
    mkdir -p "${path}/project/test/modules/${newModule}"
    mv "${path}/project/test/modules/${oldModule}${newName}" "${path}/project/test/modules/${newModule}"
}

function show_help()
{
    local -a list
    list="help"
    list=("${list[@]}" "Usage :xt [OPTIONS]")
    list=("${list[@]}" "  -m: 将model的字段变为函数的声明参数")
    list=("${list[@]}" "      @如: createTime: { type: Date }, // 创建时间 -> createTime, //创建时间")
    list=("${list[@]}" "  -p: 将函数的声明参数去除注释作为函数调用参数")
    list=("${list[@]}" "      @如: createTime, //创建时间 -> createTime,")
    list=("${list[@]}" "  -j: 将函数的声明参数添加参数空字符串作为调试参数，用于测试用例")
    list=("${list[@]}" "      @如: createTime, //创建时间 -> createTime: '', //创建时间")
    list=("${list[@]}" "  -o: 将函数的声明参数添加参数数字1作为调试参数")
    list=("${list[@]}" "      @如: createTime, //创建时间 -> createTime: 1, //创建时间")
    list=("${list[@]}" "  -e: 所有的注释用分号分开")
    list=("${list[@]}" "      @如: createTime, //创建时间\nname, //姓名 -> 创建时间;姓名")
    list=("${list[@]}" "  -f: 将所有的声明参数连接起来作为调用参数")
    list=("${list[@]}" "      @如: createTime,[ //创建时间]\nname,[ //姓名] -> createTime, name")
    list=("${list[@]}" "  -a: 通过正则表达式替换 (reg:±num|str|func, 注意\和=>需要转义成\\\\和=\>)")
    list=("${list[@]}" "  -l delimiter: 转化为list，分隔符为delimiter,否则\r?\n或者,|;|，|；")
    list=("${list[@]}" "      @如: 1 2 3 4 5 -> ['1','2','3','4','5']")
    list=("${list[@]}" "  -d n: n为数字获取第n列的数据，否则按照公式生成")
    list=("${list[@]}" "      @如: -d 0: 1 2\n3 4 -> 1\n3")
    list=("${list[@]}" "      @如: -d #0:#1: 1 2\n3 4 -> 1:2\n3:4")
    list=("${list[@]}" "  -x: 获取xml的文字部分")
    list=("${list[@]}" "  -n type: 将剪切板的内容转化为json格式 0: js 1: json 2:inline-js 3:inline-json")
    list=("${list[@]}" "  -t: 将calss转化为style，如 .item { border-width: 1px; } -> item: { borderWidth: 1 }, ")
    list=("${list[@]}" "  -g: 将div转化为View，span转化为Text")
    list=("${list[@]}" "  -c: 将英文的符号改变为中文的符号")
    list=("${list[@]}" "  -C: 将中文的符号改变为英文的符号")
    list=("${list[@]}" "  -w oldModule/oldName:[newMoule/]newName[,oldname1:newname1]: 生成pc端所有的代码")
    list=("${list[@]}" "      @如: common/organizationType:common/article,组织类型:文章")
    list=("${list[@]}" "  -s oldModule/oldName:[newMoule/]newName[,oldname1:newname1]: 生成server端所有的代码")
    list=("${list[@]}" "  --help: 全部帮助")
    __msgbox "${list[@]}"
    exit
}
function show_full_help()
{
    local -a list
    list="help"
    list=("${list[@]}" "Usage :xt [OPTIONS]")
    list=("${list[@]}" "  -m: 将model的字段变为函数的声明参数")
    list=("${list[@]}" "      @如: createTime: { type: Date }, // 创建时间 -> createTime, //创建时间")
    list=("${list[@]}" "  -p: 将函数的声明参数去除注释作为函数调用参数")
    list=("${list[@]}" "      @如: createTime, //创建时间 -> createTime,")
    list=("${list[@]}" "  -j: 将函数的声明参数添加参数空字符串作为调试参数，用于测试用例")
    list=("${list[@]}" "      @如: createTime, //创建时间 -> createTime: '', //创建时间")
    list=("${list[@]}" "  -o: 将函数的声明参数添加参数数字1作为调试参数")
    list=("${list[@]}" "      @如: createTime, //创建时间 -> createTime: 1, //创建时间")
    list=("${list[@]}" "  -e: 所有的注释用分号分开")
    list=("${list[@]}" "      @如: createTime, //创建时间\nname, //姓名 -> 创建时间;姓名")
    list=("${list[@]}" "  -f: 将所有的声明参数连接起来作为调用参数")
    list=("${list[@]}" "      @如: createTime,[ //创建时间]\nname,[ //姓名] -> createTime, name")
    list=("${list[@]}" "  -a: 通过正则表达式替换 (reg:±num|str|func, 注意\和=>需要转义成\\\\和=\>)")
    list=("${list[@]}" "      如果为func，使用=xx的格式，参数为(m, i, _, m)，其中m为匹配到的参数，i为序号[从1开始]，_为lodash, m为moment")
    list=("${list[@]}" "      @如: [ -a 1:fang ] : createTime: 1, //创建时间 -> createTime: fang, //创建时间")
    list=("${list[@]}" "      @如: [ -a 1:=m+4 ] : createTime: 1, //创建时间 -> createTime: 14, //创建时间")
    list=("${list[@]}" "      @如: [ -a 1:=+m+4 ] : createTime: 1, //创建时间 -> createTime: 5, //创建时间")
    list=("${list[@]}" "      @如: [ -a 1:=i+4 ] : createTime: 1, //创建时间 -> createTime: 4, //创建时间")
    list=("${list[@]}" "      @如: [ -a \\\\d:=+m+4 ] : createTime: 1, //创建时间 -> createTime: 5, //创建时间")
    list=("${list[@]}" "      @如: [ -a *:=\\\`pre\\ \\\${m}\\ post\\\` ] : createTime ->pre createTime post")
    list=("${list[@]}" "      @如: [ -a *:=\"\\\"pre \\\"+m+\" post\\\"\" ] : createTime ->pre createTime post")
    list=("${list[@]}" "      @如: [ -a *:=\"\\\"pre \\\"+m+\" post\\\"\" ] : createTime ->pre createTime post")
    list=("${list[@]}" "      @如: [ -a *:=\\\`{\\ type:\\ \\\${i-1}\\\,\\ name:\\ \\\"\${m}\\\"\\ },\\\` ] : createTime ->{ type: 0, name: \"createTime\" },")
    list=("${list[@]}" "  -l delimiter: 转化为list，分隔符为delimiter,否则\r?\n或者,|;|，|；")
    list=("${list[@]}" "      @如: 1 2 3 4 5 -> ['1','2','3','4','5']")
    list=("${list[@]}" "  -d n: n为数字获取第n列的数据，否则按照公式生成")
    list=("${list[@]}" "      @如: -d 0: 1 2\n3 4 -> 1\n3")
    list=("${list[@]}" "      @如: -d #0:#1: 1 2\n3 4 -> 1:2\n3:4")
    list=("${list[@]}" "  -x: 获取xml的文字部分")
    list=("${list[@]}" "  -n type: 将剪切板的内容转化为json格式 0: js 1: json 2:inline-js 2:inline-json")
    list=("${list[@]}" "  -t: 将calss转化为style，如 .item { border-width: 1px; } -> item: { borderWidth: 1 }, ")
    list=("${list[@]}" "  -g: 将div转化为View，span转化为Text")
    list=("${list[@]}" "  -c: 将英文的符号改变为中文的符号")
    list=("${list[@]}" "  -C: 将中文的符号改变为英文的符号")
    list=("${list[@]}" "  -w oldModule/oldName:[newMoule/]newName[,oldname1:newname1]: 生成pc端所有的代码")
    list=("${list[@]}" "      @如: common/organizationType:common/article,组织类型:文章")
    list=("${list[@]}" "  -s oldModule/oldName:[newMoule/]newName[,oldname1:newname1]: 生成server端所有的代码")
    __msgbox "${list[@]}"
    exit
}

function main()
{
    local oper_right param
    oper_right=0

    if [ "$1" = "--help" ];then
        show_full_help
    fi

    while getopts :mpojtl:xefa:n:w:s:d:cgCh opt;do
        oper_right=1
        case $opt in
            m)_oper=1;;
            p)_oper=2;;
            o)_oper=3;;
            j)_oper=4;;
            a)_oper=5;param="$OPTARG";;
            x)_oper=6;;
            n)_oper=16;param="$OPTARG";;
            c)_oper=7;;
            C)_oper=8;;
            l)_oper=9;param="$OPTARG";;
            e)_oper=10;;
            w)_oper=11;param="$OPTARG";;
            s)_oper=12;param="$OPTARG";;
            d)_oper=15;param="$OPTARG";;
            f)_oper=13;;
            t)_oper=14;;
            g)_oper=17;;
            *)show_help;;
        esac
    done

    case $_oper in
        1)genrate_param_from_model;;
        2)genrate_param_without_comment;;
        3)genrate_param_for_one;;
        4)genrate_param_for_js;;
        5)add_for_number "${param}";;
        6)get_text_from_xml;;
        7)change_english_symbol_to_chinese;;
        8)change_chinese_symbol_to_english;;
        9)to_list "${param}";;
        15)to_list_index "${param}";;
        10)join_all_comment;;
        11)gen_pc_code "${param}";;
        12)gen_server_code "${param}";;
        13)join_all_params;;
        14)class_to_style;;
        17)div_to_view;;
        16)change_to_json "${param}";;
        *)show_help;;
    esac
}

main "$@"
